package com.baozhun.mall.common.model.bean

import androidx.annotation.Keep
import java.io.Serializable

/**
 * @Title：常用地址
 * @Description：
 * @Author：xing.luo
 * @Since：2022/11/25
 * @Version：1.0.0
 */
@Keep
class AddressInfo(
    var id: Int,
    var phone: String,
    var receive_name: String,
    var province_id: String,
    var province: String,
    var city_id: String,
    var city: String,
    var county: String,
    var county_id: String,
    var address: String,
    var street: String,
    var street_id: String,
    var is_default: Int //0 否 1 是
) : Serializable {

    fun isDefault(): Boolean {
        return 1 == is_default
    }

    fun getNameAndPhone(): String {
        return "$receive_name $phone"
    }

    fun getDetailAddress(): String {
        if (province == city && city == county) {
            return province + street
        }
        if (province == city) {
            return province + county + street
        }
        return province + city + county + street
    }

    fun getDetailAddressWith(): String {
        return getDetailAddress() + address
    }

    override fun toString(): String {
        return receive_name + phone + province + city + county + street + address
    }
}